package com.cloudspace.jindun.update;

import com.cloudspace.jindun.config.Configs;
import com.cloudspace.jindun.network.HttpManager;
import com.cloudspace.jindun.network.api.BaseAPI;
import com.cloudspace.jindun.network.base.ApiCallback;
import com.cloudspace.jindun.network.base.GsonRequest;
import com.cloudspace.jindun.network.base.RequestFactory;

/**
 * Created by zengxianhua on 17/3/8.
 */

public class UpdateApi extends BaseAPI{
    private StringBuilder getBaseRequestUrl(){
        return new StringBuilder(String.format("http://%s/jindun/%s/myself/updateapp",
                Configs.SERVER_IP,Configs.API_VERSION));
    }

    public void getUpdateInfo(String tag, ApiCallback<UpdateInfoResult> callback){
        String url = getBaseRequestUrl().toString();

        GsonRequest request = RequestFactory.newInstance()
                .create(url, UpdateInfoResult.class, callback)
                .setNoCache();

        HttpManager.addRequest(request, tag);
    }
}
